<template>
  <details-layout
    :data="data"
    :related="related"
    channel="achievement"
    titleField="名称"
    dateField="日期"
    contentField="描述">
    <div class="title text-center q-px-lg">{{data.名称}}</div>
    <div class="info row no-wrap relative-position justify-end">
      <div class="type absolute-center">{{$t('类型')}}: {{data.类型}}</div>
      <div class="date">{{data.日期 | normalDate}}</div>
    </div>
    <div class="details" v-html="data.详情"></div>
  </details-layout>
</template>

<script>
import mixins from 'eis-admin-mixins';
import DetailsLayout from '../../components/detailsLayout.vue';
import { RefreshOnIDChange, RefreshRelatedOnIDChange } from '../../components/mixins/data';
import { GoHomeOnLocaleChange } from '../../components/mixins/locale';

export default {
  name: 'AchievementDetails',
  mixins: [mixins.ObjectDataMixin, GoHomeOnLocaleChange,
    RefreshOnIDChange, RefreshRelatedOnIDChange],
  components: {
    DetailsLayout,
  },
  data() {
    return {
      related: [],
    };
  },
  created() {
    this.getRelated();
  },
  methods: {
    getRelated() {
      this.getRequest(`/portal/achievements/related/${this.$route.params.id}`, { limit: 5 }).then((d) => {
        if (d && d.msg === 'OK') {
          this.related = d.data.docs;
        }
      });
    },
  },
};
</script>
